package com.smart.config;

import java.util.List;
import com.google.common.collect.Lists;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.ApiInfo;
import org.springframework.context.annotation.Bean;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.spring.web.plugins.Docket;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;

/**
 * @author lgb
 * @date 2020年6月8日 下午8:14:42
 * Copyright (C) 深圳工勘科技
 * @说明: Swagger2API文档的配置
 **/
@Configuration
@EnableKnife4j
@EnableSwagger2
public class Swagger2Config {
	
	@Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
               .apiInfo(this.apiInfo()).select()
               .apis(RequestHandlerSelectors.basePackage("com.smart.controller"))
               .paths(PathSelectors.any()).build()
               .securitySchemes(this.securitySchemes());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("智慧工地后台管理系统")
            .description("智慧工地后台管理系统")
            .termsOfServiceUrl("http://localhost:9001/")
            .version("1.0").build();
    }

    private List<ApiKey> securitySchemes() {
        return Lists.newArrayList(new ApiKey("Authorization","Authorization","header"));
    }
    
}